class Person < ActiveRecord::Base
  has_many :administrators
  has_many :teams
  
  
  ##
  # renders the first, last and username name of the peron
  # in the format Paul Russell
  def full_name
    output = ''
    if !self.first_name.nil? 
      output += self.first_name
    end
    if !self.first_name.nil?  && !self.last_name.nil? 
       output += " "
    end
    if !self.last_name.nil? 
      output += self.last_name
    end
    if output == ''
      output += self.username
    end
    output
  end
  
  ##
  # renders the first, last and username name of the peron
  # in the format Paul Russell (parussel)  
  def full_name_and_username
     full_name << ' (' << self.username << ')'
  end
   
  ##
  # defaults the display of a persons name to their full
  # name and username 
  def name
    full_name_and_username
  end
  
  ##
  # renders the person in csv format 
  # this is used to render generator ownership files
  def as_csv
    output = ''
    if !self.username.nil? 
      output += self.username  
    end
    output += ','
    if !self.first_name.nil? 
      output += self.first_name  
    end
    output += ','
    if !self.last_name.nil? 
      output += self.last_name  
    end
    output
  end
  
    
end
